package com.example.demo;

import cn.hutool.core.thread.ThreadUtil;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import org.opencv.core.*;
import org.opencv.core.Point;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

import javax.imageio.ImageIO;
import javax.sound.midi.Soundbank;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class StartApplication {
    //闯关坐标x,y
    public static int chuangGuanx = 821;
    public static int chuangGuany = 459;

    //过关斩将坐标x,y
    public static int guoGuanx = 128;
    public static int guoGuany = 581;

    //好友组队坐标x,y
    public static int randomMatchingX = 365;
    public static int randomMatchingY = 567;

    //没有匹配到重开坐标x,y
    public static int xX = 1025;
    public static int xY = 77;

    //截屏x,y
    public static int jiex = 699;
    public static int jiey = 294;
    //截屏 宽高
    public static int jieWidth = 70;
    public static int jieyHigh = 40;

    //选英雄x,y 428,346
    public static int selectX = 469;
    public static int selectY = 454;

    //准备x,y 428,346
    public static int prepareX = 541;
    public static int prepareY = 597;

    public static volatile boolean preFlag = true;


    //玩家二点击加入房间
    public static int per2JoinX = 1372;
    public static int per2JoinY = 462;

    //玩家二选择英雄
    public static int select2X = 1214;
    public static int select2Y = 377;

    //玩家二准备
    public static int prepare2X = 1498;
    public static int prepare2Y = 502;


    //玩家三点击加入房间
    public static int per3JoinX = 1346;
    public static int per3JoinY = 971;

    //玩家三选择英雄
    public static int select3X = 1619;
    public static int select3Y = 903;

    //玩家三准备
    public static int prepare3X = 1488;
    public static int prepare3Y = 1003;

    //截图所有卡牌位置
    public static int templateX = 134;
    public static int templateY = 459;

    //截图所有卡牌数字位置

    public static int templateNumberX = 139;
    public static int templateNumberY = 463;


    public static int templateHigh = 25;
    public static int templateWidth = 700;

    /**
     * 毫秒 MILLISECONDS
     * 秒 SECONDS
     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        ThreadUtil.sleep(1000, TimeUnit.MILLISECONDS);
        Robot robot = new Robot();

        //Rectangle rectangle = new Rectangle(jiex, jiey, jieWidth, jieyHigh);
        Rectangle rectangle = new Rectangle(templateNumberX, templateNumberY, templateWidth, templateHigh);
        //Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage image = robot.createScreenCapture(rectangle);
        File file1 = new File("E:\\java\\ideaWorks\\yingxiongsha\\test1.png");
        ImageIO.write(image, "png", file1);
        System.out.println("屏幕截图保存成功！");


        File file = new File("E:\\java\\ideaWorks\\yingxiongsha\\test1.png");
        ITesseract ins = new Tesseract();
        ins.setDatapath("E:\\java\\ideaWorks\\utools\\Tess4J\\tessdata");
        ins.setLanguage("chi_sim");
        String result = ins.doOCR(file);

        System.out.println("result" + result);

//        pre1(robot);
//        pre2(robot);
//        pre3(robot);

        //m2();
        //m1();

        //图片匹配
        //simpleMatch();
        // multipleMatch();
        //选卡牌
        //multipleMatch1();
    }

    /**
     * 精简过后的代码 识别杀在哪个位置
     *
     * @param robot
     * @throws Exception
     */
    public static void template22(Robot robot) throws Exception {

        //Rectangle rectangle = new Rectangle(jiex, jiey, jieWidth, jieyHigh);
        Rectangle rectangle = new Rectangle(templateX, templateY, 700, 250);
        //Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage image = robot.createScreenCapture(rectangle);
        File file = new File("n2.png");
        ImageIO.write(image, "png", file);
        System.out.println("屏幕截图保存成功！");


        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat srcImage = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\n2.png");
        HighGui.imshow("poker", srcImage);
        HighGui.waitKey(0);

        Mat templateImage = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\sha.jpg");
        HighGui.imshow("template", templateImage);
        HighGui.waitKey(0);

        Mat result = new Mat();
        Imgproc.matchTemplate(srcImage, templateImage, result, Imgproc.TM_CCOEFF_NORMED);

        // 执行模板匹配
        Mat resultImage = new Mat();
        Imgproc.matchTemplate(srcImage, templateImage, resultImage, Imgproc.TM_CCOEFF_NORMED);

        // 获取最大匹配值的坐标
        Core.MinMaxLocResult mmr = Core.minMaxLoc(resultImage);
        Point matchLoc = mmr.maxLoc;

        // 在源图像上绘制匹配区域的矩形框
        Imgproc.rectangle(srcImage, matchLoc, new Point(matchLoc.x + templateImage.cols(), matchLoc.y + templateImage.rows()), new Scalar(255, 0, 0), 2);
        HighGui.imshow("match", srcImage);
        HighGui.waitKey(0);
        int windowX = (int) matchLoc.x + templateX;
        int windowY = (int) matchLoc.y + templateY;
        System.out.println("windowX: " + windowX);
        System.out.println("windowY: " + windowY);
        System.out.println("结束");

        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(windowX, windowY);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);


        //选择敌人
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(65, 314);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

        //杀
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(399, 421);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
    }

    public static void template11(Robot robot) throws Exception {
        ThreadUtil.sleep(1000, TimeUnit.MILLISECONDS);
        //Rectangle rectangle = new Rectangle(jiex, jiey, jieWidth, jieyHigh);
        Rectangle rectangle = new Rectangle(templateX, templateY, 700, 250);
        //Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage image = robot.createScreenCapture(rectangle);
        File file = new File("n2.png");
        ImageIO.write(image, "png", file);
        System.out.println("屏幕截图保存成功！");


        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat srcImage = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\n2.png");
//        HighGui.imshow("poker", srcImage);
//        HighGui.waitKey(0);

        Mat templateImage = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\sha.jpg");
//        HighGui.imshow("template", templateImage);
//        HighGui.waitKey(0);

        Mat result = new Mat();
        Imgproc.matchTemplate(srcImage, templateImage, result, Imgproc.TM_CCOEFF_NORMED);

        // 执行模板匹配
        Mat resultImage = new Mat();
        Imgproc.matchTemplate(srcImage, templateImage, resultImage, Imgproc.TM_CCOEFF_NORMED);

        // 获取最大匹配值的坐标
        Core.MinMaxLocResult mmr = Core.minMaxLoc(resultImage);
        Point matchLoc = mmr.maxLoc;

        // 在源图像上绘制匹配区域的矩形框
        Imgproc.rectangle(srcImage, matchLoc, new Point(matchLoc.x + templateImage.cols(), matchLoc.y + templateImage.rows()), new Scalar(255, 0, 0), 2);
//        HighGui.imshow("match", srcImage);
//        HighGui.waitKey(0);
        int windowX = (int) matchLoc.x + templateX;
        int windowY = (int) matchLoc.y + templateY;
        System.out.println("windowX: " + windowX);
        System.out.println("windowY: " + windowY);
        System.out.println("结束");

        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(windowX, windowY);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);


        //选择敌人
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(65, 314);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

        //杀
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(399, 421);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
    }

    /**
     * 多个图片
     */
    private static void multipleMatch() {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat srcImage = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\kapai02.png");
        HighGui.imshow("poker", srcImage);
        HighGui.waitKey(0);

        Mat templateImage = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\kapai.jpg");
        HighGui.imshow("template", srcImage);
        HighGui.waitKey(0);

        Mat resultImage = new Mat();
        Imgproc.matchTemplate(srcImage, templateImage, resultImage, Imgproc.TM_CCOEFF_NORMED);
        System.out.println("result" + resultImage);

        // 设置匹配结果阈值,用于过滤低相关性的匹配点
        double threshold = 0.8;
        // 获取所有局部最大值
        List<Rect> locations = new ArrayList<>();
        double minVal, maxVal;
        Point matchLoc;
        for (int i = 0; i < resultImage.rows(); i++) {
            for (int j = 0; j < resultImage.cols(); j++) {
                double val = resultImage.get(i, j)[0];
                if (val >= threshold) {
                    // 计算匹配区域的坐标和大小
                    int x = j;
                    int y = i;
                    int width = templateImage.cols();
                    int height = templateImage.rows();

                    // 限制坐标和大小,确保不超出图像边界
                    x = Math.max(x, 0);
                    y = Math.max(y, 0);
                    width = Math.min(width, srcImage.cols() - x);
                    height = Math.min(height, srcImage.rows() - y);

                    locations.add(new Rect(x, y, width, height));
                }
            }
        }

        // 在源图像上绘制矩形框
        for (Rect loc : locations) {
            Imgproc.rectangle(srcImage, loc, new Scalar(0, 0, 255), 2);
        }

        // 显示结果图像
        HighGui.imshow("Matches", srcImage);
        HighGui.waitKey(0);



        /*//匹配
        Mat result = new Mat();
        Imgproc.matchTemplate(src, template, result, Imgproc.TM_CCOEFF_NORMED);
        System.out.println("result" + result);

        float[] p = new float[3];
        int tempRow = template.rows();
        int tempCol = template.cols();
        System.out.println("rows"+result.rows());
        for (int i = 0; i < result.rows(); i++) {
            for (int j = 0; j < result.cols(); j++) {
                result.get(i,j,p);

                if(p[0]>0.5){
                    System.out.println("pppp");
                    Imgproc.rectangle(src,new Point(j,i),new Point(j+tempCol,i+tempRow), new Scalar(0, 0, 255), 2,Imgproc.LINE_AA);
                }
            }
        }*/
    }

    /**
     * 单个图片模版匹配
     */
    private static void multipleMatch1() {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\n2.png");
        HighGui.imshow("poker", src);
        HighGui.waitKey(0);

        Mat template = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\hongtao.jpg");
        HighGui.imshow("template", template);
        HighGui.waitKey(0);

        Mat result = new Mat();
        Imgproc.matchTemplate(src, template, result, Imgproc.TM_CCOEFF_NORMED);
        System.out.println("result" + result);
        Core.MinMaxLocResult mmr = Core.minMaxLoc(result);
        Point loc = mmr.maxLoc;

        int srcImageX = 392;
        int srcImageY = 724;
        int srcImageWidth = 800;
        int srcImageHeight = 350;

        // 计算模板在 Windows 窗口坐标系下的位置


        // 计算模板在Windows窗口坐标系下的位置
        int templateX = (int) loc.x;
        int templateY = (int) loc.y;
        int templateWidth = template.cols();
        int templateHeight = template.rows();
        int windowX = srcImageX + templateX;
        int windowY = srcImageY + templateY;


        // 打印模板在Windows窗口坐标系下的位置信息
        System.out.println("模板在Windows窗口坐标系下的坐标: (" + windowX + ", " + windowY + ")");
        System.out.println("模板在Windows窗口坐标系下的宽度: " + templateWidth);
        System.out.println("模板在Windows窗口坐标系下的高度: " + templateHeight);
        System.out.println("templateX: " + templateX);
        System.out.println("templateY: " + templateY);
//
//        System.out.println(loc.x);
//        System.out.println(loc.y);
        Imgproc.rectangle(src, loc, new Point(loc.x + template.cols(), loc.y + template.rows()), new Scalar(255, 0, 0));
        HighGui.imshow("match", src);
        HighGui.waitKey(0);
        System.out.println("结束");

        /*//匹配
        Mat result = new Mat();
        Imgproc.matchTemplate(src, template, result, Imgproc.TM_CCOEFF_NORMED);
        System.out.println("result" + result);

        float[] p = new float[3];
        int tempRow = template.rows();
        int tempCol = template.cols();
        System.out.println("rows"+result.rows());
        for (int i = 0; i < result.rows(); i++) {
            for (int j = 0; j < result.cols(); j++) {
                result.get(i,j,p);

                if(p[0]>0.5){
                    System.out.println("pppp");
                    Imgproc.rectangle(src,new Point(j,i),new Point(j+tempCol,i+tempRow), new Scalar(0, 0, 255), 2,Imgproc.LINE_AA);
                }
            }
        }*/
    }

    /**
     * 杀图片模版匹配(单个)
     */
    private static void simpleMatch() {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\kapai01.jpg");
        HighGui.imshow("poker", src);
        HighGui.waitKey(0);

        Mat template = Imgcodecs.imread("E:\\java\\ideaWorks\\yingxiongsha\\kapai.jpg");
        HighGui.imshow("template", src);
        HighGui.waitKey(0);

        int method = Imgproc.TM_CCORR_NORMED;

        int width = src.cols() - template.cols() + 1;
        int height = src.rows() - template.rows() + 1;
        // 创建32位模板匹配结果Mat
        Mat result = new Mat(width, height, CvType.CV_32FC1);
        Imgproc.matchTemplate(src, template, result, method);
        //Imgproc.matchTemplate(src, template, result, Imgproc.TM_CCOEFF_NORMED);
        System.out.println("result" + result);

        Core.MinMaxLocResult mmr = Core.minMaxLoc(result);
        double x, y;
        if (method == Imgproc.TM_SQDIFF_NORMED || method == Imgproc.TM_SQDIFF) {
            x = mmr.minLoc.x;
            y = mmr.minLoc.y;
        } else {
            x = mmr.maxLoc.x;
            y = mmr.maxLoc.y;
        }
        Imgproc.rectangle(src, new Point(x, y), new Point(x + template.cols(), y + template.rows()), new Scalar(0, 0, 255), 2, Imgproc.LINE_AA);

        HighGui.imshow("模板匹配", src);
        HighGui.waitKey();


    }

    private static void pre2(Robot robot) {
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(per2JoinX, per2JoinY);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);


        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //选择英雄x,y
        robot.mouseMove(select2X, select2Y);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //选择英雄x,y
        robot.mouseMove(prepare2X, prepare2Y);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
    }

    private static void pre3(Robot robot) {
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //加入游戏x,y
        robot.mouseMove(per3JoinX, per3JoinY);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);


        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //选择英雄x,y
        robot.mouseMove(select3X, select3Y);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //选择英雄x,y
        robot.mouseMove(prepare3X, prepare3Y);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
    }

    private static void m2() throws TesseractException {
        //从英雄杀首页到斩将匹配的随机页面
        //项羽 韩信 吕瘙 刘邦
        String success = "项羽";
        //pre1();
        //m1();
        //File file = new File("D:\\develop\\ideaWork\\yingxiongsha\\匹配正确的2.png");
        File file = new File("D:\\develop\\ideaWork\\yingxiongsha\\匹配正确的.png");
        ITesseract ins = new Tesseract();
        ins.setDatapath("D:\\develop\\tess4j\\Tess4J-3.4.8-src\\Tess4J\\tessdata");
        ins.setLanguage("chi_sim");
        String result = ins.doOCR(file);

        System.out.println(result);
        System.out.println(result.substring(0, 2).equalsIgnoreCase(success));
    }

    private static void m1() {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("zj1.jpg");
        HighGui.imshow("poker", src);
        HighGui.waitKey(0);
        Mat m1 = Imgcodecs.imread("screenshot.png");
        HighGui.imshow("poker1", m1);
        HighGui.waitKey(0);


        //匹配
        Mat result = new Mat();
        Imgproc.matchTemplate(src, m1, result, Imgproc.TM_CCOEFF_NORMED);
        System.out.println(result);
    }

    /**
     * 从英雄杀首页到斩将匹配的随机页面
     *
     * @throws AWTException
     */
    private static void pre1(Robot robot) throws Exception {
        // 移动鼠标到指定的坐标

        //停2秒
        ThreadUtil.sleep(2, TimeUnit.SECONDS);
        // 创建Robot对象


        robot.mouseMove(chuangGuanx, chuangGuany);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        //截屏
        /*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle rectangle = new Rectangle(screenSize);
        BufferedImage image = robot.createScreenCapture(rectangle);
        File file = new File("screenshot.png");
        ImageIO.write(image, "png", file);
        System.out.println("屏幕截图保存成功！");*/
        //TODO 匹配阶段 感觉要方法包起来，while循环匹配成功才退出循环
        //停顿毫秒
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //过关斩将坐标x,y
        robot.mouseMove(guoGuanx, guoGuany);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);


        while (preFlag) {
            //TODO 这边会有问题。可能斩将时间过了或者没开始需要匹配
            //停顿毫秒
            ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
            //好友组队坐标x,y
            robot.mouseMove(randomMatchingX, randomMatchingY);
            // 模拟鼠标左键点击
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

            //停顿毫秒
            ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
            //截屏
            Rectangle rectangle = new Rectangle(jiex, jiey, jieWidth, jieyHigh);
            BufferedImage image = robot.createScreenCapture(rectangle);
            File file = new File("n1.png");
            ImageIO.write(image, "png", file);
            System.out.println("屏幕截图保存成功！");

            //对比
            ITesseract ins = new Tesseract();
            ins.setDatapath("D:\\develop\\tess4j\\Tess4J-3.4.8-src\\Tess4J\\tessdata");
            ins.setLanguage("chi_sim");
            String result = ins.doOCR(new File("D:\\develop\\ideaWork\\yingxiongsha\\n1.png"));

            System.out.println(result);
            ThreadUtil.sleep(1000, TimeUnit.MILLISECONDS);
            boolean flag = result.substring(0, 2).equalsIgnoreCase("项羽");
            System.out.println(flag);
            if (flag) {
                preFlag = false;
                break;
            }
            //没有匹配到重开坐标x,y
            robot.mouseMove(xX, xY);
            // 模拟鼠标左键点击
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
            System.out.println(flag);
        }

        //选英雄
        robot.mouseMove(selectX, selectY);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        //停顿毫秒
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);

        //点击准备
        robot.mouseMove(prepareX, prepareY);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        //停顿毫秒
        ThreadUtil.sleep(500, TimeUnit.MILLISECONDS);
        //1518,265
        //随机匹配坐标x,y
/*        int dianjix =1518;
        int dianjiy =265;
        robot.mouseMove(dianjix, dianjiy);
        // 模拟鼠标左键点击
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);*/
    }
}
